<style lang="less">
    @import '../../styles/common.less';
</style>

<template>
    <div>
    <Form :label-width="100">
           <Card>
             <p slot="title">
            <Icon type="navicon-round"></Icon>
            留言回复
        </p>   
        
        <p style="margin:10px 0;">
        </p>
        <Row>
            <i-Col span="24"> 
                 <row>
                <i-col span="8">                
                    <Form-item label="留言人">                
                        {{model.username}}
                    </Form-item>
                </i-col>
                <i-col span="8">  
                    <Form-item label="电话">                
                        {{model.tel}}
                    </Form-item>
                </i-col>
                <i-col span="8"> 
                    <Form-item label="邮箱">                
                        {{model.email}}
                    </Form-item>
                </i-col>
            </row>        
                        <FormItem label="类型">
                            {{model.leixing}}
                        </FormItem>
                        <FormItem label="标题">
                            {{model.title}}
                        </FormItem>
                        <FormItem label="内容">
                            {{model.content}}
                        </FormItem>         
            </i-Col>
        </Row>  
                    <FormItem label="回复内容">
                        <i-Input type="textarea" v-model="model.recontent">
                        </i-Input>
                    </FormItem>        
            <Form-item>
                <i-button type="primary" @click="save">提交</i-button>
            </Form-item>
                </Card>
                
    </Form>
    </div>
</template>

<script>
import api from '../../libs/api';
export default {
    name: 'content_liuyanadd',
    data () {
        return {     
            model:{},
        };
    },
    methods:{
        save(){            
            var vm=this;    
            api.post("/liuyans/save",this.model).then(function(res){
                if(vm.model.ID>0)
                    vm.$Message.success("修改成功！");
                else                    
                    vm.$Message.success("添加成功！");
                    vm.$router.push({
                        name: 'content_liuyan',
                        query: {}
                    });
            })
        },
        getxinxi(callback){
            var id=this.$route.query.ID;
            var vm=this;
            api.post("/liuyans/getone/"+id+"?t="+new Date().getSeconds()).then(function(res){
                vm.model=res.data.msg;   
                callback();
            })
        },
        init () {
            var vm=this;
            var id=this.$route.query.ID;
            if(id>0){
                
                    vm.getxinxi();          
            }
            else{
            }
        }
    },
    mounted () {
        this.init();
        
    },
    watch: {
        '$route' () {
            this.init();
        }
    }
};
</script>
